import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getAddressListApi } from '@/api/address'

export const useAddressStore = defineStore(
  'address',
  () => {
    const addressList = ref([])

    const getAddressList = async () => {
      const { data: { list } } = await getAddressListApi()
      addressList.value = list
    }

    return {
      addressList, getAddressList
    }
  }, {
    persist: {
      key: 'address', // 指定存储的 key
      storage: localStorage // 指定存储方式，默认是 localStorage
    }
  })
